#include "StdAfx.h"
#include "IOperation.h"

namespace HotKeyOperation
  {
//------------------------------------------------------------------------

  IOperation::IOperation(unsigned int i_delay_before, unsigned int i_delay_after)
    :m_delay_before(i_delay_before)
    ,m_delay_after(i_delay_after)
    {
    }

  void IOperation::Operate()
    {
    Sleep(m_delay_before);

    DoOperate();

    Sleep(m_delay_after);

    if (m_next_operation.get() != 0 )
      m_next_operation->Operate();
    }

//------------------------------------------------------------------------

  void IOperation::AddOperation(IOperation * i_ioperation)
    {
    if (m_next_operation.get() == 0)
      m_next_operation.reset(i_ioperation);
    else
      m_next_operation->AddOperation(i_ioperation);
    }

//------------------------------------------------------------------------

  NullOperation::NullOperation(unsigned int i_delay /*= 0*/)
    :IOperation(i_delay, 0)
    {
    }

//------------------------------------------------------------------------
  }